import request from '@/common/request'
import useUserStore from '@/store/user'
import type { AnyObject, TRequestData } from '@/common/types'

// 登录
export function login(data:TRequestData) {
  return request.post('/login/tel', data)
}

// 获取短信验证码
export function getSendMsg(data:TRequestData) {
  return request.post('/auth/sendMsg', data)
}

// 获取附近技师列表
export function getTechnician(data:TRequestData) {
  return request.post('/technician/nearby', data)
}

// 判断是否进入技师中心
export function toUserInfo() {
  return request.post('/user/info')
}

// 获取上传腾讯云参数
export function getUploadToken(type?:'technician-material') {
  return request.post('/auth/getUploadAuth', { type })
}

// 获取个人信息
export async function getUserInfo() {
  const res = await request.post('/technician/profile')
  Object.assign(useUserStore().userInfo, res.data)
}

// 申请入驻
export function applyToJoin(data:TRequestData) {
  return request.post('/technicianApply/applyToJoin', data)
}

// 更新资料
export function updateInfo(data:TRequestData) {
  return request.post('/technician/update', data)
}

// 更新坐标信息
export function updatelocation(data:TRequestData) {
  return request.post('/user/sync', data)
}

// 提交资质认证
export function addTechnicianMaterial(data:TRequestData) {
  return request.post('/technicianMaterial/add', data)
}

// 更新服务状态
export function updateServiceStatus(data:TRequestData) {
  return request.post('/technician/updateServiceStatus', data)
}

// 更新服务状态
export function updateServiceDistance(data:TRequestData) {
  return request.post('/technician/updateServiceDistance', data)
}

// 查询资质信息
export function getTechnicianMaterial() {
  return request.post('/technicianMaterial/getBy')
}

// 查询技师详情
export function getTechnicianDetail(data:TRequestData) {
  return request.post('/technician/homepageDetail', data)
}

// 获取充值列表
export function getGoodList() {
  return request.post('/good/list')
}

// 获取用户积分
export function getPoint() {
  return request.post('/userPoint/getPoint')
}

// 获取用户积分记录
export function getPointList(data:AnyObject) {
  return request.post('/userPoint/pageByBill', data)
}

// 显示技师联系方式
export function showContact(tno:string) {
  return request.post('/technician/showContact', { tno })
}

// 解锁技师联系方式
export function unlockContact(tno:string) {
  return request.post('/pay/unlockContact', { tno })
}

// 获取用户评价列表
export function getUserComment(data:AnyObject) {
  return request.post('/userComment/pageBy', data)
}

// 获取技师收到的评价列表
export function getTechnicianComment(data:AnyObject) {
  return request.post('/technicianComment/pageBy', data)
}

// 用户评价技师
export function addComment(data:AnyObject) {
  return request.post('/userComment/addComment', data)
}

// 用户购买历史记录
export function userPayHistory(data:AnyObject) {
  return request.post('/userPayHistory/pageBy', data)
}

// 用户删除评论
export function deleteComment(data:AnyObject) {
  return request.post('/userComment/deleteComment', data)
}

// 用户删除评分
export function deleteCommentStar(data:AnyObject) {
  return request.post('/userComment/deleteCommentStar', data)
}
// 技师删除评论
export function deleteCommentTechnician(data:AnyObject) {
  return request.post('/technicianComment/deleteComment', data)
}

// 搜索技师
export function searchTechnician(data:AnyObject) {
  return request.post('/technician/search/byNickname', data)
}

// 技师收到联系记录
export function getTechnicianContactHistory(data:AnyObject) {
  return request.post('/technicianContactHistory/pageBy', data)
}

// 用户删除历史记录
export function deleteUserContactRecord(data:AnyObject) {
  return request.post('/userPayHistory/deleteUserContactRecord', data)
}

// 技师删除历史记录
export function technicianDeleteUserContactRecord(data:AnyObject) {
  return request.post('/technicianContactHistory/deleteContactRecord', data)
}

// 技师添加举报
export function technicianAddReport(data:AnyObject) {
  return request.post('/report/technician/add', data)
}

// 用户举报技师
export function userAddReport(data:AnyObject) {
  return request.post('/report/user/add', data)
}

// 获取登录验证码
export function sendMsg(data:AnyObject) {
  return request.post('/login/sendMsg', data)
}

// 意见反馈
export function feedBack(data:AnyObject) {
  return request.post('/feedBack/add', data)
}

// 商务合作
export function contactUs(data:AnyObject) {
  return request.post('/contactUs/add', data)
}

// 支付
export function payByGood(data:AnyObject) {
  return request.post('/pay/payByGood', data)
}

// H5支付
export function payByGoodH5(data:AnyObject) {
  return request.post('/pay/payH5ByGood', data)
}

// 获取保证金
export function getDeposit() {
  return request.post('/good/getDeposit')
}

// 获取保证金
export function addWithdrawInfo(data:AnyObject) {
  return request.post('/withdrawInfo/add', data)
}

// 检查是否获取联系方式
export function isUnlockContact(tno:string) {
  return request.post('/technician/isUnlockContact', { tno })
}

// 客户查询技师详情
export function detailTechnician(data:AnyObject) {
  return request.post('/technician/detail', data)
}

// 客户查询技师
export function userGetTechnicianMaterial(data:AnyObject) {
  return request.post('/technicianMaterial/getByTno', data)
}

// 用户注销
export function appleCancelAccount() {
  return request.post('/user/appleCancelAccount')
}

// 获取订单价格
export function getBillPoint(goodType:string) {
  return request.post('/pay/getBillPoint', { goodType })
}

// 添加退款
export function addOrderRefund(data:AnyObject) {
  return request.post('/orderRefund/add', data)
}

// 添加预约
export function addServiceAppointment(data:AnyObject) {
  return request.post('/serviceAppointment/add', data)
}

// 用户获取预约列表
export function userGetServiceAppointment(data:AnyObject) {
  return request.post('/serviceAppointment/user/pageBy', data)
}

// 技师获取预约列表
export function technicianGetServiceAppointment(data:AnyObject) {
  return request.post('/serviceAppointment/technician/pageBy', data)
}

// 获取预约详情
export function getServiceAppointmentDetail(data:AnyObject) {
  return request.post('/serviceAppointment/getBy', data)
}

// 修改预约状态
export function updateStateServiceAppointment(data:AnyObject) {
  return request.post('/serviceAppointment/updateState', data)
}

// 用户删除预约记录
export function userDeleteServiceAppointment(data:AnyObject) {
  return request.post('/serviceAppointment/user/delete', data)
}

// 技师删除预约记录
export function technicianDeleteServiceAppointment(data:AnyObject) {
  return request.post('/serviceAppointment/technician/delete', data)
}

// 添加实名认证
export function addRealNameAuth(data:AnyObject) {
  return request.post('/realNameAuth/add', data)
}

// 获取实名认证
export function getRealNameAuth() {
  return request.post('/realNameAuth/getBy')
}

// 获取安卓审核
export function getHonorAuditConfig() {
  return request.post('/config/getHonorAuditConfig')
}

// 获取平台资质
export function getPlatformQualificationConfig() {
  return request.post('/config/getPlatformQualificationConfig')
}

/* #ifdef H5*/
// 获取jssdk参数
export function getJsapiSign(url:string) {
  return request.post('/login/getJsapiSign', { url })
}

// 微信登录
export function loginByWx(code:string) {
  return request.post('/login/loginByWx', { code })
}
/* #endif*/

/* #ifdef APP-PLUS*/
// 获取最新版本
export function getLatestVersion(data:AnyObject) {
  return request.post('/appVersion/getLatestVersion', data)
}

// 获取苹果审核
export function getAppleAuditConfig() {
  return request.post('/config/getAppleAuditConfig')
}

// 更新个性化推荐
export function updatePersonalization(isPersonalization:number) {
  return request.post('/user/updatePersonalization', { isPersonalization })
}
/* #endif*/
